package com.example.springboot_jxc_0511.jxc.controller;


import com.example.springboot_jxc_0511.jxc.entity.Product;
import com.example.springboot_jxc_0511.jxc.entity.Sale;
import com.example.springboot_jxc_0511.jxc.entity.Users;
import com.example.springboot_jxc_0511.jxc.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gongxl
 * @since 2021-05-11
 */
@Controller
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private IProductService iProductService;

    @RequestMapping("getProductList")
    @ResponseBody
    public List<Product> getProductList(){
        //视图名
        List<Product> productList = iProductService.list();
        return productList;
    }

    @RequestMapping("/toXsKcY")
    public String toXsKcY(Model model,String productid) {
        Product pro = iProductService.getById(productid);
        List<Product> productList = iProductService.list();
        model.addAttribute("productList", productList);
        model.addAttribute("pageFlag", "xs_kc_yw");
        model.addAttribute("pro", pro);
        model.addAttribute("productid", productid);
        return "yang";
    }

}

